package pl.edu.agh.student.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

/**
 * Class implementing the basic properties of all entities.
 */
@MappedSuperclass
public abstract class AbstractEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    
    private Long id;
    private Date lastChange;
    private Integer version;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    @Basic
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="last_change")
    public Date getLastChange() {
        return lastChange;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setLastChange(Date lastChange) {
        this.lastChange = lastChange;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
    
}
